<template>
  <basic-container class="app-container">
    <div class="ordertablist">
      <span class="name" v-for="(item,index) in ordertablist" :class="{active:(indexs==index)}" @click="handleTabs(index)"
        :key="index">{{item.name}}</span>
    </div>
    <div class="orderMain">
      <div v-if="indexs==0">
        <Nationalorders></Nationalorders>
      </div>
      <div v-if="indexs==1">
        <CustomerService></CustomerService>
      </div>
      <div v-if="indexs==2">
        <Orderwithdelivery></Orderwithdelivery>
      </div>

    </div>

  </basic-container>
</template>

<script>
  import Nationalorders from '@/components/statistics-container/Nationalorders'
  import CustomerService from '@/components/statistics-container/CustomerService'
  import Delivery from '@/components/statistics-container/Delivery'
  import Orderwithdelivery from '@/components/statistics-container/Orderwithdelivery'
  import store from '@/store/';
  export default {
    components: {
      Nationalorders,
      CustomerService,
      Delivery,
      Orderwithdelivery
    },
    data() {
      return {
        indexs: 0, ////订单标签索引
        ordertablist: [
          //订单标签切换数据
          {
            name: "全国订单数量"
          },

          {
            name: "客服确认统计"
          },
          {
            name: "订单与配送统计"
          },
        ],
      }
    },
    methods: {
      handleTabs(item) { //切换订单标签数据
        this.indexs = item;
      },
    },
    created () {
      // 验证 token
      if(!window.localStorage.getItem('x-access-token')){
       store.dispatch('FedLogOut').then(() => this.$router.push({
          path: '/'
        }));
      }
    }
  }
</script>

<style lang='scss' scoped>
  .app-container {

    .ordertablist {
      display: flex;
      margin-bottom: 10px;
      cursor: pointer;

      .name {
        padding: 0 15px;
        text-align: center;
        color: #000;
        font-size: 20px;
        line-height: 40px;

        &.active {
          font-size: 20px;
          color: #43a0ff;
          border-bottom: 1px solid #43a0ff;
        }
      }
    }
    .orderMain {
      margin-bottom: 20px;
    }
  }
</style>
